package com.gm.wj.service;

import com.gm.wj.dao.WorkPublishDAO;
import com.gm.wj.entity.WorkPublish;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WorkPublishService {

    @Autowired
    private WorkPublishDAO workPublishDAO;

    /**
     * 保存
     * @param entity
     * @return
     */
    public boolean save(WorkPublish entity){
        workPublishDAO.save(entity);
        return true;
    }


    /**
     * 保存
     * @param id
     * @return
     */
    public WorkPublish getById(Integer id){
       return workPublishDAO.findById(id).orElse(null);
    }


    /**
     * 批量删除
     * @param ids
     * @return
     */
    public Integer deleteById(List<Integer> ids){
        if(ids.size()>0) {
            return workPublishDAO.deleteWorkPublishs(ids);
        }else {
            return null;
        }
    }


    /**
     * 获取列表
     * @return
     */
    public List<WorkPublish> list(){
        return workPublishDAO.findAll();
    }

}
